<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php 
if(OUTPUT_FORMAT == 'json')
{
	$items = $adc->getAdCats();
	if($items)
	{
		//echo strpos($_SERVER['HTTP_REFERER'], '/c/');
		$i = 0;
		foreach($items as $item)
		{
			if((intval($_GET['typeId']) == 0) || (intval($_GET['typeId']) == $item->getTypeId()) || ($item->getTypeId() == 0))
			{
				
				if((strpos($_SERVER['HTTP_REFERER'], '/c/') == 0) || (($item->getLinkToTypeId() == 0) && ($item->getLinkToCatId() == 0)))
				{
					$json[$i]['id'] = $item->getId();
					$json[$i]['title'] = $item->getTitle();
					$i++;
				}
			}
		}
		echo json_encode($json);
	}
}
?>